from flask import Flask, request
from send_code import send_code

app = Flask(__name__)

code = ''
username = ''
password = ''

@app.route('/')
def index():
    return 'Hello, World!'

@app.route('/get_code')
def get_code():
    global code
    email = request.args.get('email')
    code = send_code(email)
    # print(code)
    return code


@app.route('/reg')
def reg():
    global code
    global username
    global password
    username = request.args.get('username')
    password = request.args.get('password')
    user_code = str(request.args.get('code'))
    if code == user_code:
        return '注册成功'
    else:
        return '注册失败'

if __name__ == '__main__':
    app.run()